﻿@{
    ViewBag.Title = "Free Entry";
}

<!-- Ajax functions -->
<script type="text/javascript">
    function AddFreeEntry(date, hours) {
        $.ajax({
            url: "/FreeEntry/AddFreeEntry",
            type: 'POST',
            data: { date: date, hours: hours },
            success: function (response) {
                alert(response);
            },
            error: function (xhr) {
                alert("Error!");
            }
        });
    }
</script>

<!-- js event -->
<script type="text/javascript">
    $(function () {
        $("#btnAdd").click(function (evt) {
            //add free entry
            AddFreeEntry($("#inputDate").val(),
                $("#inputHours").val());
        });
    });
</script>
<div class="row-fluid">
    <div class="span2" style="text-align: left;">
        <label>
            Project</label>
    </div>
    <div class="span10" style="text-align: left;">
        <label>@ViewBag.Project</label>
    </div>

</div>
<div class="row-fluid">
    <div class="span2" style="text-align: left;">
        <label>
            Category</label>
    </div>
    <div class="span10" style="text-align: left;">
        <label>@ViewBag.Category</label>
    </div>

</div>
<div class="row-fluid">
    <div class="span2" style="text-align: left;">
        <label>
            Task</label>
    </div>
    <div class="span10" style="text-align: left;">
        <label>@ViewBag.Task</label>
    </div>

</div>
@if (!ViewBag.IsAdminRole)
{
    <div class="row-fluid">
        <div class="span2" style="text-align: left;">
            <label>
                Overhead </label></div>
        <div class="span10" style="text-align: left;">
            <div id="overheadsDropDownList">
                <select id="ddlOverhead" style="width: 580px;">
                    <option value='-1' title='Select ...'>Select ...</option>
                    @if (ViewBag.Overheads != null)
                    {
                        foreach (var overhead in ViewBag.Overheads)
                        {
                            <option @overhead.Selected value='@overhead.Category' title='@overhead.Description'>
                                @overhead.Description
                            </option>
                        }
                    }
                </select>
            </div>
        </div>
    </div>
}
<div class="row-fluid">
        <div class="span2" style="text-align: left;">
            <label>
                Date</label>
        </div>
        <div class="span10" style="text-align: left;">
            <input id="inputDate" name="inputDate" type="text" class="datepicker" size="16" />
        </div>

</div>
<div class="row-fluid">
            <div class="span2" style="text-align: left;">
                <label>
                    Hours</label></div>
            <div class="span10" style="text-align: left;">
                <input id="inputHours" name="inputHours" type="text" value="" maxlength="200" size="16" />
            </div>
</div>
<div class="row-fluid">
    <div class="span1" style="text-align: left;">
        <button id="btnAdd" class="btn actButtons" name="btnAdd">Add</button>
    </div>
    <div class="span2" style="text-align: left;">
        @Html.ActionLink("Back to Home", "Index", "EnTimeLog", null, new { @class = "btn actButtons" })
    </div>
</div>

<script type="text/javascript">
    $(function () {
        $(".datepicker").datepicker();
    });
</script>